package juc.utils.phaser;

import java.util.Random;
import java.util.concurrent.Phaser;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class PhaserExample9 {
    private final static Random random = new Random(System.currentTimeMillis());

    /**
     * 停止phaser
     */
    public static void main(String[] args) throws InterruptedException {

        final Phaser phaser = new Phaser(3);
        new Thread(phaser::arriveAndAwaitAdvance).start();
        TimeUnit.SECONDS.sleep(2);
        System.out.println("===" + phaser.isTerminated());
        TimeUnit.SECONDS.sleep(1);
        phaser.forceTermination();
        System.out.println("===" + phaser.isTerminated());

    }
}
